﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Nova_BLL;
using System.Data.SqlClient;

public partial class Left : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Nova_BLL.Menu Nova_BLL_Menu = new Nova_BLL.Menu();
        Nova_BLL.Users Nova_BLL_Users = new Nova_BLL.Users();
 
        HttpCookie Cookies = Request.Cookies["vNovaUserNo"];
        DataSet ds = null;
        DataSet dss = null;
        string vGroupNo = ""; //工作组编号
        string vUserNo = "";
        string iNode = "";         //菜单子节点编号

        if (Cookies == null || Cookies != null && Cookies.ToString() == "")
        {
            try
            {
                Response.Redirect("Default.aspx");
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
        else
        {
            vUserNo = Cookies.Value.ToString();
        }

        if (!IsPostBack)
        {
            vGroupNo = Nova_BLL_Users.CallBackGroupNo(vUserNo);
            ds = Nova_BLL_Menu.UserRole(vGroupNo);
            dlBigMenu.DataSource = ds.Tables[0].DefaultView;  //绑定主菜单
            dlBigMenu.DataBind();   

            if (dlBigMenu.Items.Count > 0)  
            {
                for (int i = 0; i < dlBigMenu.Items.Count; i++)  //分别绑定主菜单下的子菜单
                {
                    if (dlBigMenu.Items[i].ItemType == ListItemType.Item || dlBigMenu.Items[i].ItemType == ListItemType.AlternatingItem)
                    {
                        //string SmallTypeSQL = "select * from Moudle where iparentid ='" + ds.Tables[0].Rows[i]["moudleid"] + "'";
                        iNode = ds.Tables[0].Rows[i]["iNode"].ToString();
                        dss = Nova_BLL_Menu.UserRole(vGroupNo, iNode);
                        Repeater rep = (Repeater)dlBigMenu.Items[i].FindControl("dlSmenu");
                        if (rep != null)
                        {
                            rep.DataSource = dss.Tables[0].DefaultView;
                            rep.DataBind();
                        }
                    }
                }
            }

        }
    }
}
